<template>
	<view>
		<u-navbar :is-back="true" :is-fixed="true" title="黑名单"></u-navbar>
		<!-- <scroll-view scroll-y scroll-with-animation style="height: calc(100vh - 50px);" :show-scrollbar="false"> -->
		<view class="mt-3 pl-2 pr-2">
			<view v-for="(item, itemIndex) in tabContents" :key="itemIndex">
				<view class="u-line pb-2 mt-1" @click="getDiClick(item.id)">
					<view class="dfex">
						<view>{{ item.enterpriseName }}</view>
						<view>{{ item.updateTime }}</view>
					</view>
					<view class="mt-2 text-999999 font-12">{{
            item.enterprisesReason
          }}</view>
				</view>
			</view>
		</view>
		<!-- </scroll-view> -->
	</view>
</template>

<script>
	import $H from "@/common/free-lib/request.js";

	export default {
		data() {
			return {
				tabContents: [],
				pageNo: 1,
				pageSize: 10,
			};
		},

		onLoad() {
			this.getBlackList();
		},
		onReachBottom() {
			this.pageNo = this.pageNo + 1;
			this.getBlackList();
		},
		onPullDownRefresh() {
      this.tabContents = [];
      this.pageNo = 1;
      this.getBlackList();
		},
		methods: {
			open(path) {
				uni.navigateTo({
					url: "/pages/" + path,
				});
			},
			getBlackList() {
        uni.showLoading({
          title: "加载中"
        })
				$H.get(
						"/agriculture/blacklist/upper/list", {
							pageNo: this.pageNo,
							pageSize: this.pageSize,
						}, {}
					)
					.then((res) => {
            uni.hideLoading();
            uni.stopPullDownRefresh();
						if (res.result.records.length == 0) {
							uni.showToast({
								title: "没有更多啦！",
								icon: "success",
							});
							return;
						}
						const list = [];
						for (let i = 0; i < res.result.records.length; i++) {
							list.push({
								id: res.result.records[i].id,
								enterpriseName: res.result.records[i].enterpriseName,
								updateTime: res.result.records[i].updateTime,
								enterprisesReason: res.result.records[i].enterprisesReason,
							});
						}

						this.tabContents.push(...list);
					})
					.catch((error) => {
            uni.hideLoading();
            uni.stopPullDownRefresh();
						console.error("请求出错", error); // 处理任何错误
					});
			},
			getDiClick(id) {
				uni.navigateTo({
					url: "/pages/tabbar/index/blacklistDi?id=" + id,
				});
			},
		},
	};
</script>

<style>
</style>